package com.car.rental.order.util;

import com.alipay.api.internal.util.AlipaySignature;
import com.car.rental.order.config.AlipayConfig;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@RequiredArgsConstructor
public class AlipaySignUtils {
    
    private final AlipayConfig alipayConfig;
    
    public boolean verifySign(Map<String, String> params) {
        try {
            return AlipaySignature.rsaCheckV1(
                params,
                alipayConfig.getAlipayPublicKey(),
                "UTF-8",
                "RSA2"
            );
        } catch (Exception e) {
            throw new RuntimeException("验证签名失败", e);
        }
    }
} 